﻿using MetroDataApi.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Web.Http;

namespace MetroDataApi.Controllers
{
    public class ReviewRecentChangesController : ApiController
    {
        public HttpResponseMessage Get(int prjId, string monitorType, string location, DateTime date)
        {

            var change = Recent2Changes.GetChangesIncludingUnReview(prjId, monitorType, location, date.ToString("yyyy-MM-dd HH:mm:ss"));

            this.Configuration.Formatters.Clear();
            this.Configuration.Formatters.Add(new JsonMediaTypeFormatter());
            this.Configuration.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented,
                Converters = new List<JsonConverter> { new StandardFloatConverter() }
            };
            return Request.CreateResponse(HttpStatusCode.OK, change, "application/json");
        }
    }
}
